home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ktoolbarlabelaction.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.5 KB  |  138 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 2004 Felix Berger <felixberger@beldesign.de>
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License version 2 as published by the Free Software Foundation.
  7.  
  8.     This library is distributed in the hope that it will be useful,
  9.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.     Library General Public License for more details.
  12.  
  13.     You should have received a copy of the GNU Library General Public License
  14.     along with this library; see the file COPYING.LIB.  If not, write to
  15.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.     Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef KTOOLBARLABELACTION_H
  19. #define KTOOLBARLABELACTION_H
  20.  
  21. #include <kactionclasses.h>
  22.  
  23. class QLabel;
  24.  
  25. /**
  26.  * @short Class to display a label in a toolbar.
  27.  *
  28.  * KToolBarLabelAction is a convenience class for displaying a label in a
  29.  * toolbar.
  30.  *
  31.  * It provides easy access to the label's #setBuddy(QWidget*) and #buddy()
  32.  * methods and can be used as follows:
  33.  *
  34.  * \code
  35.  *
  36.  * KHistoryCombo* findCombo = new KHistoryCombo(true, this);
  37.  * KWidgetAction* action
  38.  *   = new KWidgetAction(findCombo, i18n("F&ind Combo"), Qt::Key_F6, this,
  39.  *                       SLOT(slotFocus()), actionCollection(), "find_combo");
  40.  *
  41.  * new KToolBarLabelAction(findCombo, i18n("F&ind "), 0, this,
  42.  *                         SLOT(slotFocus()), actionCollection(),
  43.  *             "find_label");
  44.  *
  45.  * \endcode
  46.  *
  47.  * @author Felix Berger <felixberger@beldesign.de>
  48.  */
  49. class KDEUI_EXPORT KToolBarLabelAction : public KWidgetAction
  50. {
  51. public:
  52.   /**
  53.    * Constructs a toolbar label.
  54.    *
  55.    * @param text The label's and the action's text.
  56.    * @param cut The action's shortcut.
  57.    * @param receiver The SLOT's parent.
  58.    * @param slot The SLOT to invoke to execute this action.
  59.    * @param parent This action's parent.
  60.    * @param name An internal name for this action.
  61.    */
  62.   KToolBarLabelAction(const QString &text,
  63.               const KShortcut &cut,
  64.               const QObject *receiver, const char *slot,
  65.               KActionCollection *parent, const char *name);
  66.   /**
  67.    * Constructs a toolbar label setting a buddy for the label.
  68.    *
  69.    * @param buddy The widget which is focused when the label's accelerator is
  70.    * typed.
  71.    * @param text The label's and the action's text.
  72.    * @param cut The action's shortcut.
  73.    * @param receiver The SLOT's parent.
  74.    * @param slot The SLOT to invoke to execute this action.
  75.    * @param parent This action's parent.
  76.    * @param name An internal name for this action.
  77.    */
  78.   KToolBarLabelAction(QWidget* buddy, const QString &text,
  79.               const KShortcut &cut,
  80.               const QObject *receiver, const char *slot,
  81.               KActionCollection *parent, const char *name);
  82.   /**
  83.    * Constructs a toolbar label for a label.
  84.    *
  85.    * You can use this constructor if you want to display a class which is
  86.    * derived from QLabel in the toolbar. Note that ownership of the label is
  87.    * transferred to the action and the label is deleted when the action is
  88.    * deleted. So you shouldn't hold any pointers to the label.
  89.    *
  90.    * It's important that the label's name is set to "kde toolbar widget" in
  91.    * its constructor, otherwise it is not correctly rendered in some kde
  92.    * styles.
  93.    *
  94.    * @param label the label which is displayed in the toolbar.
  95.    * @param cut The action's shortcut.
  96.    * @param receiver The SLOT's parent.
  97.    * @param slot The SLOT to invoke to execute this action.
  98.    * @param parent This action's parent.
  99.    * @param name An internal name for this action.
  100.    */
  101.   KToolBarLabelAction(QLabel* label, const KShortcut &cut, 
  102.               const QObject *receiver, const char *slot,
  103.               KActionCollection* parent, const char *name);
  104.  
  105.   virtual ~KToolBarLabelAction();
  106.   /**
  107.    * Reimplemented to update both the action's text and the label's text.
  108.    */
  109.   virtual void setText(const QString& text);
  110.   /**
  111.    * Sets the label's buddy to buddy.
  112.    *
  113.    * See QLabel#setBuddy() for details.
  114.    */
  115.   virtual void setBuddy(QWidget* buddy);
  116.   /**
  117.    * Returns the label's buddy or 0 if no buddy is currently set.
  118.    *
  119.    * See QLabel#buddy() and QLabel#setBuddy() for more information.
  120.    */
  121.   QWidget* buddy() const;
  122.   /**
  123.    * Returns the label which is used internally.
  124.    */
  125.   QLabel* label() const;
  126.  
  127. protected:
  128.   virtual void virtual_hook(int id, void* data);
  129.  
  130. private:
  131.   class KToolBarLabelActionPrivate;
  132.   KToolBarLabelActionPrivate *d;
  133.   void init();
  134. };
  135.  
  136.  
  137. #endif
  138.